import { useEffect } from 'react';

interface PageTitleOptions {
  title: string;
  description?: string;
}

export function usePageTitle({ title, description }: PageTitleOptions) {
  useEffect(() => {
    // Update document title
    document.title = `${title} | VitaIncubator`;
    
    // Update meta description if provided
    if (description) {
      const metaDescription = document.querySelector('meta[name="description"]');
      if (metaDescription) {
        metaDescription.setAttribute('content', description);
      }
    }
    
    // Update Open Graph title
    const ogTitle = document.querySelector('meta[property="og:title"]');
    if (ogTitle) {
      ogTitle.setAttribute('content', `${title} | VitaIncubator`);
    }
    
    // Update Open Graph description if provided
    if (description) {
      const ogDescription = document.querySelector('meta[property="og:description"]');
      if (ogDescription) {
        ogDescription.setAttribute('content', description);
      }
    }
  }, [title, description]);
}

// Pre-defined page titles and descriptions
export const PAGE_TITLES = {
  HOME: {
    title: 'Design Your Wellness',
    description: 'Expert reviews and recommendations for the best health and wellness products on the market.'
  },
  REVIEWS: {
    title: 'Product Reviews',
    description: 'In-depth reviews of the latest health and wellness products, tested by our expert team.'
  },
  TOP_PICKS: {
    title: 'Top Picks',
    description: 'Our expertly curated selection of the best health and wellness products for optimal results.'
  },
  GUIDES: {
    title: 'Wellness Guides',
    description: 'Comprehensive guides to help you make informed decisions about your health and wellness journey.'
  },
  ABOUT: {
    title: 'About Us',
    description: 'Learn about VitaIncubator\'s mission to help you find the best health and wellness products.'
  },
  CONTACT: {
    title: 'Contact Us',
    description: 'Get in touch with the VitaIncubator team for questions, suggestions, or partnership opportunities.'
  },
  PRIVACY: {
    title: 'Privacy Policy',
    description: 'VitaIncubator\'s privacy policy and how we protect your personal information.'
  }
} as const;
